/*
    private权限修饰符的使用
 */

public class PrivateDemo {
     private String name;
     private int age;

     public void setName(String n){
         name = n;
     }

     public String getName(){
         return name;
     }

     public void setAge(int a){
         if (a>0&&a<=120){
             age = a;
         }else{
             System.out.println("请输入正确的数字!");
         }
     }

     public int getAge(){
         return age;
     }

     public void print(){
         System.out.println("姓名是:"+name);
         System.out.println("年龄是:"+age);
     }
}
